package com.lifeng.controller;

import com.lifeng.bean.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

/**
 * Created by lifeng on 2018/4/13.
 */
@RestController
@EnableEurekaClient
public class UserConsumerController {
    @Autowired
    private RestTemplate restTemplate;

    @RequestMapping("/user/consumer/{id}")
    public Object getUser(@PathVariable String id){
        String url = "http://localhost:8084/user/"+id;
        User user = restTemplate.getForObject(url, User.class);
        return user;
    }
}
